<?php
/**
 * 系统管理员列表
 * 处理视图所需的变量
 *
 */



// 保存数据框架名
$save_frame = $_SESSION[$G_admin_session_key]['save_frame'];
$back_url   = get_current_url();
// 将当前URL保存在Cookie中，避免复杂的URL字符串
cookie('back_url', strcode($back_url));
$url_cur    = get_current_url(array('orderby', 'desc'));
// 排序
$orderlist  = array('aid', 'filename', 'filetype', 'filesize', 'isimage', 'upmod');
$arr_orderby= parse_orderby($orderlist, 'aid', $url_cur);


$key    = trim(@$_GET['key']);

$chk_inuse__1   = '';
$chk_inuse_1    = '';
$chk_inuse_0    = '';



if(!array_key_exists('inuse', $_GET)) $inuse = -1;
else $inuse  = @(int)$_GET['inuse'];
if($inuse == 1) $chk_inuse_1 = 'checked';
elseif($inuse == 0) $chk_inuse_0 = 'checked';
else $chk_inuse__1   = 'checked';


require($abs_admin_cppath . '/header.php');
?>
<div class="datacontainer1">
<form action="<?php echo $mod_url['a.li']; ?>" name="search" method="get">
<div class="new_line" style="text-align:right">
	<div class="spW10 fl"></div>
	<input type="hidden" name="mod" value="<?php echo $mod; ?>">
	<input type="hidden" name="action" value="<?php echo $action; ?>">


&nbsp;&nbsp;
使用状态：
<INPUT TYPE="radio" NAME="inuse" ID="inuse__1" value="-1" <?php echo $chk_inuse__1; ?>> <label for="inuse__1">所有</label>
<INPUT TYPE="radio" NAME="inuse" ID="inuse_1" value="1" <?php echo $chk_inuse_1; ?>> <label for="inuse_1">使用中</label>
<INPUT TYPE="radio" NAME="inuse" ID="inuse_0" value="0" <?php echo $chk_inuse_0; ?>> <label for="inuse_0">未使用</label>
&nbsp;&nbsp;
	关键字：
	<input type="text" name="key" value="<?php echo $key; ?>" size="20" class="text">

	<input type="submit" value="查询" class="btn">
	&nbsp;&nbsp;
</div>
</form>

<TABLE BORDER="0" CELLPADDING="4" CELLSPACING="1" width="100%" class="list_table">
<form action="<?php echo $mod_url['a.del']; ?>" name="items_form" target="<?php echo $save_frame ?>" method="post" onsubmit="return submit_select_items(this.name, 'item_id[]');">
<THEAD>
	<TR class="list_head">
		<TH scope=col width="40" class="textC"><a href="<?php echo $arr_orderby['aid']; ?>">#</a></TH>
		<TH scope=col width="160" class="textC"><a href="<?php echo $arr_orderby['filename']; ?>">文件名称</a></TH>
		<TH scope=col width="40" class="textC">使用</TH>
		<TH scope=col width="40"><a href="<?php echo $arr_orderby['isimage']?>">图片</a></TH>
		<TH scope=col>描述</TH>

		<TH scope=col width="80"><a href="<?php echo $arr_orderby['filetype']; ?>">文件类型</a></TH>
		<TH scope=col width="80"><a href="<?php echo $arr_orderby['filesize']?>">文件大小</a></TH>
		<TH scope=col width="80"><a href="<?php echo $arr_orderby['valid']?>">上传模块</a></TH>
		<TH scope=col width="100"><a href="<?php echo $arr_orderby['valid']?>">上传变量</a></TH>
		<TH scope=col width="80">操作</TH></TR></THEAD>
<TBODY>
<?php
$tr_class_name  = '';
if(is_array($vars['record']) && $vars['record_total'] > 0) {
    foreach($vars['record'] as $k=>$v) {
        $tr_class_name  = $tr_class_name != 'tr0' ? 'tr0' : 'tr1';
        $file_url       = $G_web_upload . $v['fileurl'];
        $file_name      = zh_substr($v['filename'], 26);
        $description    = zh_substr($v['description'], 80);
        if($description == '') $description = '&nbsp;';


        //$inuse  = @(int)$v['item_id'] > 0 ? '<span class="font_green">√</span>' : '<span class="font_red">×</span>';
        //$isimage= @(int)$v['isimage'] > 0 ? '<span class="font_green">√</span>' : '<span class="font_red">×</span>';
        if(@(int)$v['item_id'] > 0)
            $inuse    = "<div class=\"btn_yes\">{$v['item_id']}</div>";
        else
            $inuse  = "<div class=\"btn_no\">0</div>";

        if(@(int)$v['isimage'] > 0)
            $isimage    = "<div class=\"btn_yes\">{$v['isimage']}</div>";
        else
            $isimage  = "<div class=\"btn_no\">0</div>";

?>
	<TR onmouseover="return chgBg(this, 1);" onmouseout="return chgBg(this, 0);" class="<?php echo $tr_class_name?>">
		<TD width="40" class="textC"><input type="checkbox" value="<?php echo $v['aid']; ?>" name="item_id[]"></TD>
		<TD width="160"><a href="<?php echo $file_url; ?>" target="_blank"><?php echo $file_name; ?></a></TD>
		<TD width="40" class="textC"><?php echo $inuse; ?></TD>
		<TD width="40" class="textC"><?php echo $isimage; ?></TD>
		<TD><?php echo $description; ?></TD>

		<TD width="80" class="textC"><?php echo $v['filetype']; ?></TD>
		<TD width="80" class="textr"><?php echo ceil(@(int)$v['filesize']/1024); ?>K</TD>
		<TD width="80" class="textC"><?php echo $v['upmod']; ?></TD>
		<TD width="100" class="textC"><?php echo $v['upvar']; ?></TD>
		<TD width="80" class="textC">
		<span class=" fl">&nbsp;</span><a href="<?php echo $file_url; ?>" target="_blank" class="btn_img fl" title="查看">查看</a> 
		<a href="<?php echo $mod_url['a.del']; ?>&item_id=<?php echo $v['aid']; ?>" target="<?php echo $save_frame?>" onclick="return del_this();"class="btn_del fl" title="删除">删除</a>
		</TD></TR>
<?php
    }
} else {
    // 没有记录
}
?>
</TBODY>
</TABLE>
<?php
$page_info  = "共 {$vars['record_total']} 条记录 每页 {$vars['page_size']} 条 共 {$vars['page_total']} 页 ";
$page_list  = get_page_nav($vars['page_total']);
?>
<div class="page_nav">
	
	<div class="page_list_pre">
		&nbsp;&nbsp;<a href="javascript:chkbox_sel_all('items_form', 'item_id[]');"><B>全选</B></a> <a href="javascript:chkbox_sel_reverse('items_form', 'item_id[]');"><B>反选</B></a>
	</div>
	<div class="page_list">
		<?php echo $page_list?>
	</div>
	<div class="page_info">
		<?php echo $page_info ?>
	</div>
	<div id="clear_both"></div>
</div>

<div class="new_line borderTop">
<div class="spW10 fl"></div>
<input type="submit" name="del" value="删除" class="btn fl">
<input type="hidden" name="deltype" value="<?php echo $save_flag; ?>">
</div>
</form>
</div>
<?php
require($abs_admin_cppath . '/footer.php');
?>